﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hinacom.Scheduler
{
    public class JobHistory
    {
        private DateTime _startTimeUtc;
        private DateTime? _endTimeUtc;

        public int? Id { get; set; }
        public string JobName { get; set; }
        public string JobGroup { get; set; }
        public DateTime StartTimeUtc
        {
            get { return this._startTimeUtc; }
            set
            {
                if (value.Kind == DateTimeKind.Utc)
                    _startTimeUtc = value;
                else if (value.Kind == DateTimeKind.Unspecified)
                    _startTimeUtc = DateTime.SpecifyKind(value, DateTimeKind.Utc);
                else
                    _startTimeUtc = value.ToUniversalTime();
            }
        }
        public DateTime? EndTimeUtc
        {
            get { return this._endTimeUtc; }
            set
            {
                if (!value.HasValue)
                {
                    _endTimeUtc = null;
                    return;
                }
                DateTime v = value.Value;
                if (v.Kind == DateTimeKind.Utc)
                    _endTimeUtc = v;
                else if (v.Kind == DateTimeKind.Unspecified)
                    _endTimeUtc = DateTime.SpecifyKind(v, DateTimeKind.Utc);
                else
                    _endTimeUtc = v.ToUniversalTime();
            }
        }
        public JobExecutionStatus Status { get; set; }
        public string RunningLog { get; set; }
    }

    public enum JobExecutionStatus
    {
        NotStarted = 1,
        Running = 2,
        Succeeded = 3,
        Failed = 4
    }

}
